package com.example.demo;

import com.example.demo.bean.AuthorSettings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class DemoApplication {

    @Value("${book.author}")
    private String bookAuthor;
    @Value("${book.name}")
    private String bookName;

    @Autowired
    private AuthorSettings authorSettings;

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
    @RequestMapping("/index")
    public String index(){
        return  "this is "+bookAuthor+", first "+bookName+" project";
    }
        @RequestMapping("/demo1")
    public String demo1(){
        return  "this is "+authorSettings.getName()+","+authorSettings.getAge()+"岁";
    }
}
